home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 May / may_2001.iso / intercd / root / Multimedia / ^DivX_Article / virtualdub / VirtualDub-source-1_4d / Filtdlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-20  |  15.7 KB  |  574 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    Copyright (C) 1998-2001 Avery Lee
  3. //
  4. //    This program is free software; you can redistribute it and/or modify
  5. //    it under the terms of the GNU General Public License as published by
  6. //    the Free Software Foundation; either version 2 of the License, or
  7. //    (at your option) any later version.
  8. //
  9. //    This program is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. //    GNU General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU General Public License
  15. //    along with this program; if not, write to the Free Software
  16. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #include <crtdbg.h>
  19.  
  20. #include <windows.h>
  21. #include <commctrl.h>
  22. #include <commdlg.h>
  23.  
  24. #include "VideoSource.h"
  25. #include "Error.h"
  26. #include "List.h"
  27.  
  28. #include "resource.h"
  29. #include "oshelper.h"
  30. #include "ClippingControl.h"
  31. #include "error.h"
  32. #include "gui.h"
  33.  
  34. #include "filtdlg.h"
  35. #include "filters.h"
  36.  
  37. extern HINSTANCE g_hInst;
  38. extern char g_msgBuf[];
  39. extern const char g_szError[];
  40. extern FilterFunctions g_filterFuncs;
  41.  
  42. extern VideoSource *inputVideoAVI;
  43.  
  44. //////////////////////////////
  45.  
  46. BOOL APIENTRY FilterClippingDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam);
  47. void FilterLoadFilter(HWND hWnd);
  48.  
  49. //////////////////////////////
  50.  
  51. static FilterDefinition *g_selectedFilter;
  52.  
  53. void MakeFilterList(List& list, HWND hWndList) {
  54.     int count;
  55.     int ind;
  56.     FilterInstance *fa;
  57.  
  58.     if (LB_ERR == (count = SendMessage(hWndList, LB_GETCOUNT, 0, 0))) return;
  59.  
  60.     _RPT0(0,"MFL start\n");
  61.     for(ind=count-1; ind>=0; ind--) {
  62.         fa = (FilterInstance *)SendMessage(hWndList, LB_GETITEMDATA, (WPARAM)ind, 0);
  63.  
  64.         _RPT1(0,"adding: %p\n", fa);
  65.         list.AddTail(fa);
  66.     }
  67. }
  68.  
  69. static void EnableConfigureBox(HWND hdlg, int index = -1) {
  70.     HWND hwndList = GetDlgItem(hdlg, IDC_FILTER_LIST);
  71.  
  72.     if (index < 0)
  73.         index = SendMessage(hwndList, LB_GETCURSEL, 0, 0);
  74.  
  75.     if (index != LB_ERR) {
  76.         FilterInstance *fa = (FilterInstance *)SendMessage(hwndList, LB_GETITEMDATA, (WPARAM)index, 0);
  77.  
  78.         EnableWindow(GetDlgItem(hdlg, IDC_CONFIGURE), !!fa->filter->configProc);
  79.         EnableWindow(GetDlgItem(hdlg, IDC_CLIPPING), TRUE);
  80.     } else {
  81.         EnableWindow(GetDlgItem(hdlg, IDC_CONFIGURE), FALSE);
  82.         EnableWindow(GetDlgItem(hdlg, IDC_CLIPPING), FALSE);
  83.     }
  84. }
  85.  
  86. static void RedoFilters(HWND hWndList) {
  87.     List listFA;
  88.     int ind, ind2, l;
  89.     FilterInstance *fa;
  90.    int sel;
  91.  
  92.    sel = SendMessage(hWndList, LB_GETCURSEL, 0, 0);
  93.  
  94.     MakeFilterList(listFA, hWndList);
  95.  
  96.     try {
  97.         if (inputVideoAVI) {
  98.             BITMAPINFOHEADER *bmih = inputVideoAVI->getImageFormat();
  99.             filters.prepareLinearChain(&listFA, (Pixel *)(bmih+1), bmih->biWidth, bmih->biHeight, 24, 24);
  100.         } else {
  101.             filters.prepareLinearChain(&listFA, NULL, 320, 240, 24, 24);
  102.         }
  103.     } catch(MyError e) {
  104.         return;
  105.     }
  106.  
  107.     ind = 0;
  108.     fa = (FilterInstance *)listFA.tail.next;
  109.     while(fa->next) {
  110.         l = wsprintf(g_msgBuf, "%dx%d\t%dx%d\t%s"
  111.                 ,fa->src.w
  112.                 ,fa->src.h
  113.                 ,fa->dst.w
  114.                 ,fa->dst.h
  115.                 ,fa->filter->name);
  116.  
  117.         if (fa->filter->stringProc) fa->filter->stringProc(fa, &g_filterFuncs, g_msgBuf+l);
  118.  
  119.         if (LB_ERR == (ind2 = SendMessage(hWndList, LB_INSERTSTRING, (WPARAM)ind, (LPARAM)g_msgBuf)))
  120.             return;
  121.  
  122.         SendMessage(hWndList, LB_SETITEMDATA, (WPARAM)ind2, (LPARAM)fa);
  123.         SendMessage(hWndList, LB_DELETESTRING, (WPARAM)ind+1, 0);
  124.  
  125.         fa = (FilterInstance *)fa->next;
  126.         ++ind;
  127.     }
  128.  
  129.    if (sel != LB_ERR)
  130.       SendMessage(hWndList, LB_SETCURSEL, sel, 0);
  131. }
  132.  
  133. BOOL APIENTRY FilterDlgProc( HWND hDlg, UINT message, UINT wParam, LONG lParam)
  134. {
  135.     static const char szPending[]="(pending)";
  136.  
  137.     switch (message)
  138.     {
  139.         case WM_INITDIALOG:
  140.             {
  141.                 HWND hWndList = GetDlgItem(hDlg, IDC_FILTER_LIST);
  142.                 FilterInstance *fa_list, *fa;
  143.                 int index;
  144.  
  145.                 fa_list = (FilterInstance *)g_listFA.tail.next;
  146.  
  147.                 while(fa_list->next) {
  148.                     try {
  149.                         fa = fa_list->Clone();
  150.  
  151.                         if (LB_ERR != (index = SendMessage(hWndList, LB_ADDSTRING, 0, (LPARAM)szPending)))
  152.                             SendMessage(hWndList, LB_SETITEMDATA, (WPARAM)index, (LPARAM)fa);
  153.                         else
  154.                             delete fa;
  155.  
  156.                     } catch(MyError e) {
  157.                         // bleah!  should really do something...
  158.                     }
  159.  
  160.                     fa_list = (FilterInstance *)fa_list->next;
  161.                 }
  162.  
  163.                 RedoFilters(hWndList);
  164.             }
  165.             return (TRUE);
  166.  
  167.         case WM_COMMAND:
  168.             switch(LOWORD(wParam)) {
  169.             case IDC_FILTER_LIST:
  170.                 switch(HIWORD(wParam)) {
  171.                 case LBN_DBLCLK:
  172.                     SendMessage(hDlg, WM_COMMAND, MAKELONG(IDC_CONFIGURE, BN_CLICKED), (LPARAM)GetDlgItem(hDlg, IDC_CONFIGURE));
  173.                     break;
  174.                 case LBN_SELCHANGE:
  175.                     EnableConfigureBox(hDlg);
  176.                     break;
  177.                 }
  178.                 break;
  179.  
  180.             case IDC_ADD:
  181.                 if (DialogBox(g_hInst, MAKEINTRESOURCE(IDD_FILTER_LIST), hDlg, AddFilterDlgProc)) {
  182.                     int index;
  183.                     HWND hWndList = GetDlgItem(hDlg, IDC_FILTER_LIST);
  184.  
  185.                     if (LB_ERR != (index = SendMessage(hWndList, LB_ADDSTRING, 0, (LPARAM)szPending))) {
  186.                         try {
  187.                             FilterInstance *fa = new FilterInstance(g_selectedFilter);
  188.  
  189.                             fa->x1 = fa->y1 = fa->x2 = fa->y2 = 0;
  190.  
  191.                             SendMessage(hWndList, LB_SETITEMDATA, (WPARAM)index, (LPARAM)fa);
  192.  
  193.                             RedoFilters(hWndList);
  194.  
  195.                             if (fa->filter->configProc) {
  196.                                 List list;
  197.                                 bool fRemove;
  198.  
  199.                                 MakeFilterList(list, hWndList);
  200.  
  201.                                 {
  202.                                     FilterPreview fp(inputVideoAVI ? &list : NULL, fa);
  203.  
  204.                                     fa->ifp = &fp;
  205.  
  206.                                     fRemove = 0!=fa->filter->configProc(fa, &g_filterFuncs, hDlg);
  207.                                 }
  208.  
  209.                                 if (fRemove) {
  210.                                     delete fa;
  211.                                     SendMessage(hWndList, LB_DELETESTRING, (WPARAM)index, 0);
  212.                                     break;
  213.                                 }
  214.                             }
  215.  
  216.                             RedoFilters(hWndList);
  217.  
  218.                             SendMessage(hWndList, LB_SETCURSEL, (WPARAM)index, 0);
  219.                             EnableConfigureBox(hDlg, index);
  220.                         } catch(MyError e) {
  221.                             e.post(hDlg, g_szError);
  222.                         }
  223.                     }
  224.                 }
  225.                 break;
  226.  
  227.             case IDC_DELETE:
  228.                 {
  229.                     HWND hWndList = GetDlgItem(hDlg, IDC_FILTER_LIST);
  230.                     int index;
  231.  
  232.                     if (LB_ERR != (index = SendMessage(hWndList, LB_GETCURSEL, 0, 0))) {
  233.                         FilterInstance *fa = (FilterInstance *)SendMessage(hWndList, LB_GETITEMDATA, (WPARAM)index, 0);
  234.  
  235.                         delete fa;
  236.  
  237.                         SendMessage(hWndList, LB_DELETESTRING, (WPARAM)index, 0);
  238.                     }
  239.                 }
  240.                 break;
  241.  
  242.             case IDC_CONFIGURE:
  243.                 {
  244.                     HWND hWndList = GetDlgItem(hDlg, IDC_FILTER_LIST);
  245.                     int index;
  246.  
  247.                     if (LB_ERR != (index = SendMessage(hWndList, LB_GETCURSEL, 0, 0))) {
  248.                         FilterInstance *fa = (FilterInstance *)SendMessage(hWndList, LB_GETITEMDATA, (WPARAM)index, 0);
  249.  
  250.                         if (fa->filter->configProc) {
  251.                             List list;
  252.  
  253.                             MakeFilterList(list, hWndList);
  254.  
  255.                             {
  256.                                 FilterPreview fp(inputVideoAVI ? &list : NULL, fa);
  257.  
  258.                                 fa->ifp = &fp;
  259.                                 fa->filter->configProc(fa, &g_filterFuncs, hDlg);
  260.                             }
  261.                             RedoFilters(hWndList);
  262.                             SendMessage(hWndList, LB_SETCURSEL, (WPARAM)index, 0);
  263.  
  264.                         }
  265.                     }
  266.                 }
  267.                 break;
  268.  
  269.             case IDC_CLIPPING:
  270.                 {
  271.                     HWND hWndList = GetDlgItem(hDlg, IDC_FILTER_LIST);
  272.                     int index;
  273.  
  274.                RedoFilters(hWndList);
  275.  
  276.                     if (LB_ERR != (index = SendMessage(hWndList, LB_GETCURSEL, 0, 0))) {
  277.                         FilterInstance *fa = (FilterInstance *)SendMessage(hWndList, LB_GETITEMDATA, (WPARAM)index, 0);
  278.                         const unsigned long x1 = fa->x1, y1=fa->y1, x2=fa->x2, y2=fa->y2;
  279.  
  280.  
  281.                         if (DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_FILTER_CLIPPING), hDlg, FilterClippingDlgProc, (LPARAM)fa)) {
  282.                             RedoFilters(hWndList);
  283.                             SendMessage(hWndList, LB_SETCURSEL, (WPARAM)index, 0);
  284.                         } else {
  285.                             fa->x1 = x1;
  286.                             fa->y1 = y1;
  287.                             fa->x2 = x2;
  288.                             fa->y2 = y2;
  289.                         }
  290.                     }
  291.                 }
  292.                 break;
  293.  
  294.             case IDC_MOVEUP:
  295.                 {
  296.                     HWND hWndList = GetDlgItem(hDlg, IDC_FILTER_LIST);
  297.                     int index;
  298.                     LONG lpData;
  299.  
  300.                     if (LB_ERR != (index = SendMessage(hWndList, LB_GETCURSEL, 0, 0))) {
  301.                         if (index == 0) break;
  302.  
  303.                         lpData = SendMessage(hWndList, LB_GETITEMDATA, (WPARAM)index, 0);
  304.                         SendMessage(hWndList, LB_INSERTSTRING, (WPARAM)index-1, (LPARAM)szPending);
  305.                         SendMessage(hWndList, LB_SETITEMDATA, (WPARAM)index-1, (LPARAM)lpData);
  306.                         SendMessage(hWndList, LB_DELETESTRING, (WPARAM)index+1, 0);
  307.                         RedoFilters(hWndList);
  308.                         SendMessage(hWndList, LB_SETCURSEL, (WPARAM)index-1, 0);
  309.                     }
  310.                 }
  311.                 break;
  312.  
  313.             case IDC_MOVEDOWN:
  314.                 {
  315.                     HWND hWndList = GetDlgItem(hDlg, IDC_FILTER_LIST);
  316.                     int index, count;
  317.                     LONG lpData;
  318.  
  319.                     if (LB_ERR != (index = SendMessage(hWndList, LB_GETCURSEL, 0, 0))) {
  320.                         if (LB_ERR != (count = SendMessage(hWndList, LB_GETCOUNT, 0, 0))) {
  321.                             if (index == count-1) break;
  322.  
  323.                             lpData = SendMessage(hWndList, LB_GETITEMDATA, (WPARAM)index, 0);
  324.                             SendMessage(hWndList, LB_INSERTSTRING, (WPARAM)index+2, (LPARAM)szPending);
  325.                             SendMessage(hWndList, LB_SETITEMDATA, (WPARAM)index+2, (LPARAM)lpData);
  326.                             SendMessage(hWndList, LB_DELETESTRING, (WPARAM)index, 0);
  327.                             RedoFilters(hWndList);
  328.                             SendMessage(hWndList, LB_SETCURSEL, (WPARAM)index+1, 0);
  329.                         }
  330.                     }
  331.                 }
  332.                 break;
  333.  
  334.             case IDOK:
  335.                 {
  336.                     HWND hwndList = GetDlgItem(hDlg, IDC_FILTER_LIST);
  337.                     FilterInstance *fa, *fa2;
  338.  
  339.                     fa = (FilterInstance *)g_listFA.tail.next;
  340.  
  341.                     while(fa2 = (FilterInstance *)fa->next) {
  342.                         _RPT1(0,"Deleting %p\n", fa);
  343.                         fa->ForceNoDeinit();
  344.  
  345.                         delete fa;
  346.  
  347.                         fa = fa2;
  348.                     }
  349.  
  350.                     g_listFA.Init();
  351.  
  352.                     MakeFilterList(g_listFA, hwndList);
  353.                 }
  354.                 EndDialog(hDlg, TRUE);
  355.                 return TRUE;
  356.             case IDCANCEL:
  357.                 {
  358.                     HWND hWndList = GetDlgItem(hDlg, IDC_FILTER_LIST);
  359.                     List list;
  360.                     FilterInstance *fa, *fa2;
  361.  
  362.                     MakeFilterList(list, hWndList);
  363.  
  364.                     fa = (FilterInstance *)list.tail.next;
  365.                     while(fa2 = (FilterInstance *)fa->next) {
  366.                         fa->ForceNoDeinit();
  367.                         delete fa;
  368.                         fa = fa2;
  369.                     }
  370.                 }
  371.                 EndDialog(hDlg, FALSE);
  372.                 return TRUE;
  373.             }
  374.             break;
  375.     }
  376.     return FALSE;
  377. }
  378.  
  379. void AddFilterDlgInit(HWND hDlg) {
  380.     static INT tabs[]={ 175 };
  381.  
  382.     HWND hWndList = GetDlgItem(hDlg, IDC_FILTER_LIST);
  383.     FilterDefinition *fd = filter_list;
  384.     int index;
  385.  
  386.     SendMessage(hWndList, LB_SETTABSTOPS, 1, (LPARAM)tabs);
  387.     SendMessage(hWndList, LB_RESETCONTENT, 0, 0);
  388.  
  389.     while(fd) {
  390.         wsprintf(g_msgBuf,"%s\t%s",fd->name,fd->maker?fd->maker:"(internal)");
  391.         index = SendMessage(hWndList, LB_ADDSTRING, 0, (LPARAM)g_msgBuf);
  392.         SendMessage(hWndList, LB_SETITEMDATA, (WPARAM)index, (LPARAM)fd);
  393.         fd=fd->next;
  394.     }
  395. }
  396.  
  397. BOOL APIENTRY AddFilterDlgProc( HWND hDlg, UINT message, UINT wParam, LONG lParam)
  398. {
  399.     switch (message)
  400.     {
  401.         case WM_INITDIALOG:
  402.             AddFilterDlgInit(hDlg);
  403.             return (TRUE);
  404.  
  405.         case WM_COMMAND:
  406.             switch(HIWORD(wParam)) {
  407.             case LBN_SELCANCEL:
  408.                 SendMessage(GetDlgItem(hDlg, IDC_FILTER_INFO), WM_SETTEXT, 0, (LPARAM)"");
  409.                 break;
  410.             case LBN_SELCHANGE:
  411.                 {
  412.                     FilterDefinition *fd;
  413.                     int index;
  414.  
  415.                     if (LB_ERR != (index = SendMessage((HWND)lParam, LB_GETCURSEL, 0, 0))) {
  416.                         fd = (FilterDefinition *)SendMessage((HWND)lParam, LB_GETITEMDATA, (WPARAM)index, 0);
  417.  
  418.                         SendMessage(GetDlgItem(hDlg, IDC_FILTER_INFO), WM_SETTEXT, 0, (LPARAM)fd->desc);
  419.                     }
  420.                 }
  421.                 break;
  422.             case LBN_DBLCLK:
  423.                 SendMessage(hDlg, WM_COMMAND, MAKELONG(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hDlg, IDOK));
  424.                 break;
  425.             default:
  426.                 switch(LOWORD(wParam)) {
  427.                 case IDOK:
  428.                     {
  429.                         int index;
  430.                         HWND hWndList = GetDlgItem(hDlg, IDC_FILTER_LIST);
  431.  
  432.                         if (LB_ERR != (index = SendMessage(hWndList, LB_GETCURSEL, 0, 0))) {
  433.                             g_selectedFilter = (FilterDefinition *)SendMessage(hWndList, LB_GETITEMDATA, (WPARAM)index, 0);
  434.  
  435.                             EndDialog(hDlg, TRUE);
  436.                         }
  437.                     }
  438.                     return TRUE;
  439.                 case IDCANCEL:
  440.                     EndDialog(hDlg, FALSE);
  441.                     return TRUE;
  442.                 case IDC_LOAD:
  443.                     FilterLoadFilter(hDlg);
  444.                     AddFilterDlgInit(hDlg);
  445.                     return TRUE;
  446.                 }
  447.             }
  448.             break;
  449.     }
  450.     return FALSE;
  451. }
  452.  
  453.  
  454. BOOL APIENTRY FilterClippingDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam) {
  455.     FilterInstance *fa;
  456.  
  457.     switch (message)
  458.     {
  459.         case WM_INITDIALOG:
  460.             {
  461.                 ClippingControlBounds ccb;
  462.                 LONG hborder, hspace;
  463.                 RECT rw, rc, rcok, rccancel;
  464.                 HWND hWnd, hWndCancel;
  465.  
  466.                 fa = (FilterInstance *)lParam;
  467.                 SetWindowLong(hDlg, DWL_USER, (LONG)fa);
  468.  
  469.                 hWnd = GetDlgItem(hDlg, IDC_BORDERS);
  470.                 ccb.x1    = fa->x1;
  471.                 ccb.x2    = fa->x2;
  472.                 ccb.y1    = fa->y1;
  473.                 ccb.y2    = fa->y2;
  474.  
  475. /*                if (inputVideoAVI) {
  476.                     BITMAPINFOHEADER *bmi = inputVideoAVI->getImageFormat();
  477.                     SendMessage(hWnd, CCM_SETBITMAPSIZE, 0, MAKELONG(bmi->biWidth,bmi->biHeight));
  478.                 } else
  479.                     SendMessage(hWnd, CCM_SETBITMAPSIZE, 0, MAKELONG(320,240));*/
  480.  
  481.                 SendMessage(hWnd, CCM_SETBITMAPSIZE, 0, MAKELONG(fa->src.w,fa->src.h));
  482.                 SendMessage(hWnd, CCM_SETCLIPBOUNDS, 0, (LPARAM)&ccb);
  483.  
  484.                 guiPositionInitFromStream(hWnd);
  485.  
  486.                 GetWindowRect(hDlg, &rw);
  487.                 GetWindowRect(hWnd, &rc);
  488.                 hborder = rc.left - rw.left;
  489.                 ScreenToClient(hDlg, (LPPOINT)&rc.left);
  490.                 ScreenToClient(hDlg, (LPPOINT)&rc.right);
  491.  
  492.                 SetWindowPos(hDlg, NULL, 0, 0, (rc.right - rc.left) + hborder*2, (rw.bottom-rw.top)+(rc.bottom-rc.top), SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE);
  493.  
  494.                 hWndCancel = GetDlgItem(hDlg, IDCANCEL);
  495.                 hWnd = GetDlgItem(hDlg, IDOK);
  496.                 GetWindowRect(hWnd, &rcok);
  497.                 GetWindowRect(hWndCancel, &rccancel);
  498.                 hspace = rccancel.left - rcok.right;
  499.                 ScreenToClient(hDlg, (LPPOINT)&rcok.left);
  500.                 ScreenToClient(hDlg, (LPPOINT)&rcok.right);
  501.                 ScreenToClient(hDlg, (LPPOINT)&rccancel.left);
  502.                 ScreenToClient(hDlg, (LPPOINT)&rccancel.right);
  503.                 SetWindowPos(hWndCancel, NULL, rc.right - (rccancel.right-rccancel.left), rccancel.top + (rc.bottom-rc.top), 0,0,SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE);
  504.                 SetWindowPos(hWnd, NULL, rc.right - (rccancel.right-rccancel.left) - (rcok.right-rcok.left) - hspace, rcok.top + (rc.bottom-rc.top), 0,0,SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE);
  505.             }
  506.  
  507.             return (TRUE);
  508.  
  509.         case WM_COMMAND:
  510.             switch(LOWORD(wParam)) {
  511.             case IDOK:
  512.                 {
  513.                     ClippingControlBounds ccb;
  514.  
  515.                     fa = (FilterInstance *)GetWindowLong(hDlg, DWL_USER);
  516.                     SendMessage(GetDlgItem(hDlg, IDC_BORDERS), CCM_GETCLIPBOUNDS, 0, (LPARAM)&ccb);
  517.                     fa->x1 = ccb.x1;
  518.                     fa->y1 = ccb.y1;
  519.                     fa->x2 = ccb.x2;
  520.                     fa->y2 = ccb.y2;
  521.                     EndDialog(hDlg, TRUE);
  522.                 }
  523.                 return TRUE;
  524.             case IDCANCEL:
  525.                 EndDialog(hDlg, FALSE);
  526.                 return TRUE;
  527.             case IDC_BORDERS:
  528.                 fa = (FilterInstance *)GetWindowLong(hDlg, DWL_USER);
  529.                 guiPositionBlit((HWND)lParam, guiPositionHandleCommand(wParam, lParam), fa->src.w, fa->src.h);
  530.                 return TRUE;
  531.             }
  532.             break;
  533.  
  534.             case WM_NOTIFY:
  535.                 guiPositionBlit(((NMHDR *)lParam)->hwndFrom, guiPositionHandleNotify(wParam, lParam));
  536.                 break;
  537.  
  538.     }
  539.     return FALSE;
  540. }
  541.  
  542. ///////////////////////////////////////////////////////////////////////
  543.  
  544. void FilterLoadFilter(HWND hWnd) {
  545.     OPENFILENAME ofn;
  546.     char szFile[MAX_PATH];
  547.  
  548.     szFile[0]=0;
  549.  
  550.     ofn.lStructSize            = sizeof(OPENFILENAME);
  551.     ofn.hwndOwner            = hWnd;
  552.     ofn.lpstrFilter            = "VirtualDub filter (*.vdf)\0*.vdf\0Windows Dynamic-Link Library (*.dll)\0*.dll\0All files (*.*)\0*.*\0";
  553.     ofn.lpstrCustomFilter    = NULL;
  554.     ofn.nFilterIndex        = 1;
  555.     ofn.lpstrFile            = szFile;
  556.     ofn.nMaxFile            = sizeof szFile;
  557.     ofn.lpstrFileTitle        = NULL;
  558.     ofn.nMaxFileTitle        = 0;
  559.     ofn.lpstrInitialDir        = NULL;
  560.     ofn.lpstrTitle            = "Load external filter";
  561.     ofn.Flags                = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLESIZING;
  562.     ofn.lpstrDefExt            = NULL;
  563.  
  564.     if (GetOpenFileName(&ofn)) {
  565.         try {
  566.             FilterLoadModule(szFile);
  567.         } catch(MyError e) {
  568.             e.post(hWnd,"Filter load error");
  569.         }
  570.     }
  571. }
  572.  
  573.  
  574.